<template>
	<div style="display: flex;flex-direction: column;" class="otherPage corporateNews enterpriseDynamicsList">
		<Header :selected="4"></Header>
		<div class="bannerArea">
			<div class="banner" :style="bg_img? 'background:url('+bg_img+') no-repeat;background-size:cover;':''">
			</div>
		</div>
		<Navigation v-loading="loading" :items="breadcrumbItems" :menus="menus" :bgColor="bgColor" :checked="1">
		</Navigation>
		<div class="content">
			<div class="content_bg">
				<el-row :gutter="6">
					<el-col :span="24" class="newArea" v-for="(news, index) in newsList" :key="index">
						<div class="news-list" @click="goToDetail(news.id)">
							<el-row :gutter="6" class="news-item" :class="{ 'hover': hoverIndex === index }"
								@mouseover="hoverIndex = index" @mouseleave="hoverIndex = -1">
								<el-col :span="enterpriseDynamicsLeft_xs" class="newsImg">

									<img style="" :src="news.fileUrl"></img>

								</el-col>
								<el-col :span="enterpriseDynamicsRight_xs" class="newcontent">
									<div class="newcontentcontainer">
										<div class="title" :title="news.titles">{{ news.titles }}</div>
										<div class="description">
											<p>{{$request.formartContent(news.content) }}</p>
										</div>

										<div class="moreInfoBtn" @click="goToDetail(news.id)">{{$t("moreDetails")}}
										</div>
									</div>
								</el-col>
							</el-row>
						</div>
					</el-col>
				</el-row>

				<el-row :gutter="24" type="flex" class="paginationArea">
					<el-pagination background :current-page.sync="currentPage" :page-size="pageSize"
						:layout="isShowJumper?'prev, pager, next,total,jumper ':'prev, next,total' "  :total="total"
						:prev-text="$t('previousPage')" :next-text="$t('nextPage')"
						@current-change="handleCurrentChange" />
				</el-row>
			</div>
		</div>
		<Footer></Footer>
	</div>
</template>

<script>
	import Header from '../../../src/components/common/header/Header.vue'
	import Navigation from '../../../src/components/common/navigation/Navigation.vue'
	import Footer from '../../../src/components/common/footer/Footer.vue'
	import Pagination from '../../../src/components/common/Pagination.vue'
	import {
		corporateNews
	} from '../../utils/menu.js'
	import {
		getStore,
		setStore
	} from '../../utils/tools.js';
	export default {
		components: {
			Header,
			Navigation,
			Footer,
			Pagination
		},
		data() {
			return {
				loading: true,
				bg_img: '', //头部banner，默认值已绑定，有背景自动切换
				bgColor: "white", //white/red
				pageSize: 4,
				total: 0,
				currentPage: 1,
				menus: corporateNews,
				breadcrumbItems: [{
						//首页
						label: this.$t('home'),
						to: '/home'
					},
					{
						//企业新闻
						label: this.$t('corporateNews'),
						to: '/corporateNews'
					},
					{
						//公告公示
						label: this.$t('enterpriseDynamics'),
						to: '/enterpriseDynamics'
					}
				],
				newsList: [],
				hoverIndex: -1,
				enterpriseDynamicsLeft_xs: 4,
				enterpriseDynamicsRight_xs: 20,
				isShowJumper: true
			};
		},
		computed: {},
		created() {
			this.enterpriseDynamicsLeft_xs = window.innerWidth < 460 ? 7 : 4;
			this.enterpriseDynamicsRight_xs = window.innerWidth < 460 ? 17 : 20;
			if (window.innerWidth < 768) {
				this.isShowJumper = false;
			}
			this.bindList();
			window.addEventListener('resize', this.handleWindowResize);
		},
		destroyed() {
			window.removeEventListener('resize', this.handleWindowResize);
		},
		mounted() {
			this.bindBg();
		},
		methods: {
			handleWindowResize() {
				if (window.innerWidth < 460) {
					this.enterpriseDynamicsLeft_xs = 7;
					this.enterpriseDynamicsRight_xs = 17;
				} else if (window.innerWidth < 660) {
					this.enterpriseDynamicsLeft_xs = 5;
					this.enterpriseDynamicsRight_xs = 19;
				} else if (window.innerWidth < 768) {
					this.enterpriseDynamicsLeft_xs = 4;
					this.enterpriseDynamicsRight_xs = 20;
				} else {
					this.enterpriseDynamicsLeft_xs = 4;
					this.enterpriseDynamicsRight_xs = 20;
				}
			},
			/**
			 * (1)	获取企业新闻顶部背景
			 */
			bindBg() {
				let params = {};
				let that = this;
				that.$request.qydtBgImage(params).then(res => {
					this.bg_img = this.$request.getImgUrl() + res.data.fileUrl
				}).catch((error) => {
					console.log(error);
				});

			},
			/**
			 * (1)	获取企业新闻列表
			 */
			bindList() {
				let enterprisePage = parseInt(getStore("enterprisePage"));
				this.currentPage = enterprisePage > 0 ? enterprisePage : this.currentPage;
				let params = {
					"pageNum": this.currentPage,
					"pageSize": this.pageSize
				};
				let that = this;
				that.$request.enterpriseTrendsPage(params).then(res => {
					this.newsList = res.data.records;
					this.pageSize = res.data.size;
					this.total = res.data.total;
					this.currentPage = res.data.current;
					this.loading = false;
				}).catch((error) => {
					console.log(error);
				});

			},
			///////获取点击页码，请求接口
			handleCurrentChange(currentPage) {
				this.currentPage = currentPage;
				setStore("enterprisePage", this.currentPage);
				this.bindList();
			},
			//////跳转详情页面
			goToDetail(id) {
				this.$router.push({
					name: this.$t("enterpriseDynamicsDetail"),
					query: {
						id: id,
					}
				});
			},

		}
	}
</script>

<style scoped>
	@import url("../../components/common/css/corporateNews/corporateNews.css");

	.enterpriseDynamicsList .newArea {
		height: auto;
	}

	.enterpriseDynamicsList .paginationArea {
		height: 70px;
		line-height: 70px;
		justify-content: center;
		padding-top: 20px;
	}

	.enterpriseDynamicsList .moreInfoBtn {
		width: 97px;
		height: 30px;
		line-height: 30px;
		border: 1px solid #EB7F20;
		border-radius: 4px;
		text-align: center;
		color: #EB7F20;
		margin-top: 20px;
		margin-left: 10px;
	}

	.enterpriseDynamicsList .moreInfoBtn:hover {
		background-color: #EB7F20;
		color: #FFF;
	}

	.enterpriseDynamicsList .news-list .news-item {
		height: 16vh;
		margin-bottom: 1vh;
	}

	.enterpriseDynamicsList .news-list .news-item .title {
		font-size: 24px;
		font-weight: 530;
		height: 50px;
		line-height: 50px;
		align-items: center;
		width: 80%;
		padding: 0px 10px;
	}

	.enterpriseDynamicsList .news-list .news-item:hover .title {
		color: #0484D7;
	}

	.enterpriseDynamicsList .news-list .newcontent .description {
		padding: 0 10px;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		overflow: hidden;
		font-size: 14px;
		opacity: 0.8;
		height: 70px;
		line-height: 35px;
	}

	.enterpriseDynamicsList .news-list .day {
		text-align: center;
		font-size: 2em;
		padding-top: 3vh;
		height: 13vh;
	}

	.enterpriseDynamicsList .news-list .month-year {
		text-align: center;
		font-size: 1.2em;
	}

	.enterpriseDynamicsList .btn-next span {
		min-width: 50px !important;
	}

	.el-pagination span:not([class*=suffix]) {
		display: inline-block;
		font-size: 13px;
		min-width: 50px !important;
		height: 28px;
		line-height: 28px;
		vertical-align: top;
		-webkit-box-sizing: border-box;
		box-sizing: border-box;
	}

	.news-item {
		margin-bottom: 20px;
		cursor: pointer;
		overflow: hidden;
		transition: transform 0.3s ease;
		/* 添加过渡效果 */
	}

	.enterpriseDynamicsList .news-item:hover {
		transform: scale(0.98)
	}


	::v-deep .el-pagination span:not([class*=suffix]) {
		display: inline-block;
		font-size: 13px;
		min-width: 50px;
		height: 28px;
		line-height: 28px;
		vertical-align: top;
		-webkit-box-sizing: border-box;
		box-sizing: border-box;
	}

	.enterpriseDynamicsList .newsImg {
		height: 100%;
	}

	.content_bg {
		margin: 0px auto;
		padding: 50px;

	}

	.enterpriseDynamicsList .news-list .news-item .newsImg img {
		width: 100%;
		height: 100%;
	}

	@media (min-width: 2560px) {
		.content_bg {
			width: calc(2560px * 0.8);
		}

		.enterpriseDynamicsList .news-list .news-item {
			height: calc(1px * ((2560 * 0.8 - 140) * 4 / 24 * 520 / 720));
		}

		.enterpriseDynamicsList .news-list .news-item .newsImg img {
			width: calc(1px * ((2560 * 0.8 - 140) * 4 / 24));
			height: calc(1px * ((2560 * 0.8 - 140) * 4 / 24 * 520 / 720));
		}

		.enterpriseDynamicsList .news-list .news-item {
			margin-bottom: 20px !important;
		}

		.enterpriseDynamicsList .moreInfoBtn {
			margin-top: 5px;
			height: 30px;
			line-height: 30px;
			width: 110px;
			font-size: 16px;
		}
	}

	@media (max-width: 2560px) {
		.content_bg {
			width: calc(2560px * 0.8);
		}

		.enterpriseDynamicsList .news-list .news-item {
			height: calc(1px * ((2560 * 0.8 - 140) * 4 / 24 * 520 / 720));
		}

		.enterpriseDynamicsList .news-list .news-item .newsImg img {
			width: calc(1px * ((2560 * 0.8 - 140) * 4 / 24));
			height: calc(1px * ((2560 * 0.8 - 140) * 4 / 24 * 520 / 720));
		}

		.enterpriseDynamicsList .news-list .news-item {
			margin-bottom: 20px !important;
		}

		.enterpriseDynamicsList .moreInfoBtn {
			margin-top: 5px;
			height: 30px;
			line-height: 30px;
			width: 110px;
			font-size: 16px;
		}
	}

	@media (max-width: 2320px) {
		.content_bg {
			width: calc(2320px * 0.8);
		}

		.enterpriseDynamicsList .news-list .news-item {
			height: calc(1px * ((2320 * 0.8 - 140) * 4 / 24 * 520 / 720));
		}

		.enterpriseDynamicsList .news-list .news-item .newsImg img {
			width: calc(1px * ((2320 * 0.8 - 140) * 4 / 24));
			height: calc(1px * ((2320 * 0.8 - 140) * 4 / 24 * 520 / 720));
		}

		.enterpriseDynamicsList .news-list .news-item {
			margin-bottom: 20px !important;
		}

		.enterpriseDynamicsList .moreInfoBtn {
			margin-top: 5px;
			height: 30px;
			line-height: 30px;
			width: 110px;
			font-size: 16px;
		}
	}

	@media (max-width: 2120px) {
		.content_bg {
			width: calc(2120px * 0.8);
		}

		.enterpriseDynamicsList .news-list .news-item {
			height: calc(1px * ((2120 * 0.8 - 140) * 4 / 24 * 520 / 720));
		}

		.enterpriseDynamicsList .news-list .news-item .newsImg img {
			width: calc(1px * ((2120 * 0.8 - 140) * 4 / 24));
			height: calc(1px * ((2120 * 0.8 - 140) * 4 / 24 * 520 / 720));
		}

		.enterpriseDynamicsList .news-list .news-item {
			margin-bottom: 20px !important;
		}

		.enterpriseDynamicsList .moreInfoBtn {
			margin-top: 5px;
			height: 30px;
			line-height: 30px;
			width: 110px;
			font-size: 16px;
		}
	}

	@media (max-width: 1920px) {
		.content_bg {
			width: calc(1920px * 0.8);
		}

		.enterpriseDynamicsList .news-list .news-item {
			height: calc(1px * ((1920 * 0.8 - 140) * 4 / 24 * 520 / 720));
		}

		.enterpriseDynamicsList .news-list .news-item .newsImg img {
			width: calc(1px * ((1920 * 0.8 - 140) * 4 / 24));
			height: calc(1px * ((1920 * 0.8 - 140) * 4 / 24 * 520 / 720));
		}

		.enterpriseDynamicsList .news-list .news-item {
			margin-bottom: 20px !important;
		}

		.enterpriseDynamicsList .moreInfoBtn {
			margin-top: 3px;
			height: 30px;
			line-height: 30px;
			width: 110px;
			font-size: 16px;
		}
	}

	@media (max-width: 1720px) {


		.content_bg {
			width: calc(1720px * 0.8);
		}

		.enterpriseDynamicsList .newArea,
		.enterpriseDynamicsList .newsImg,
		.news-list .newcontent,
		.news-list .newcontent .newcontentcontainer,
		.enterpriseDynamicsList .news-list .news-item {
			height: calc(1px * ((1720 * 0.8 - 140) * 4 / 24 * 520 / 720));
		}

		.enterpriseDynamicsList .news-list .news-item .newsImg img {
			width: calc(1px * ((1720 * 0.8 - 140) * 4 / 24));
			height: calc(1px * ((1920 * 0.8 - 140) * 4 / 24 * 520 / 720));
		}

		.enterpriseDynamicsList .news-list .news-item .title {
			height: 40px;
			line-height: 40px;
			font-size: 20px;
		}

		.enterpriseDynamicsList .news-list .newcontent .description {
			font-size: 14px;
			height: 60px;
			line-height: 30px;
		}

		.enterpriseDynamicsList .newArea {
			margin-bottom: 20px;
		}

		.enterpriseDynamicsList .news-list .news-item {
			margin-bottom: 20px !important;
		}

		.enterpriseDynamicsList .moreInfoBtn {
			margin-top: 6px !important;
			height: 30px;
			line-height: 30px;
			width: 97px;
		}

	}

	@media (max-width: 1520px) {
		.content_bg {
			width: calc(1520px * 0.8);
		}

		.enterpriseDynamicsList .newArea,
		.enterpriseDynamicsList .newsImg,
		.news-list .newcontent,
		.news-list .newcontent .newcontentcontainer,
		.enterpriseDynamicsList .news-list .news-item {
			height: calc(1px * ((1520 * 0.8 - 140) * 4 / 24* 520 / 720)) !important;
		}

		.enterpriseDynamicsList .news-list .news-item .newsImg img {
			width: calc(1px * ((1520 * 0.8 - 140) * 4 / 24));
			height: calc(1px * ((1520 * 0.8 - 140) * 4 / 24 * 520 / 720)) !important;
		}

		.news-list .newcontent .newcontentcontainer {
			height: calc(1px * ((1520 * 0.8 - 100) * 4 / 24 * 520 / 720)) !important;
		}

		.enterpriseDynamicsList .news-list .news-item .title {
			height: 34px;
			line-height: 34px;
			font-size: 18px;
		}

		.enterpriseDynamicsList .news-list .newcontent .description {
			font-size: 12px;
			height: 50px;
			line-height: 25px;
		}

		.enterpriseDynamicsList .newArea {
			margin-bottom: 20px;
		}

		.enterpriseDynamicsList .news-list .news-item {
			margin-bottom: 20px !important;
		}

		.enterpriseDynamicsList .moreInfoBtn {
			margin-top: 10px !important;
			height: 30px;
			line-height: 30px;
			width: 97px;
			font-size: 14px;
		}

	}

	@media (max-width: 1366px) {
		.content_bg {
			width: calc(1366px * 0.8);
		}

		.enterpriseDynamicsList .newArea,
		.enterpriseDynamicsList .newsImg,
		.news-list .newcontent,
		.news-list .newcontent .newcontentcontainer,
		.enterpriseDynamicsList .news-list .news-item {
			height: calc(1px * ((1366 * 0.8 - 140) * 4 / 24* 520 / 720)) !important;
		}

		.enterpriseDynamicsList .news-list .news-item .newsImg img {
			width: calc(1px * ((1366 * 0.8 - 140) * 4 / 24));
			height: calc(1px * ((1366 * 0.8 - 140) * 4 / 24 * 520 / 720)) !important;
		}

		.news-list .newcontent .newcontentcontainer {
			height: calc(1px * ((1366 * 0.8 - 140) * 4 / 24 * 520 / 720)) !important;
		}

		.enterpriseDynamicsList .news-list .news-item .title {
			height: 34px;
			line-height: 34px;
			font-size: 18px;
		}

		.enterpriseDynamicsList .news-list .newcontent .description {
			font-size: 12px;
			height: 50px;
			line-height: 25px;
		}

		.enterpriseDynamicsList .newArea {
			margin-bottom: 20px;
		}

		.enterpriseDynamicsList .news-list .news-item {
			margin-bottom: 20px !important;
		}

		.enterpriseDynamicsList .moreInfoBtn {
			width: 80px;
			height: 26px;
			line-height: 26px;
			margin-top: 0px !important;
			margin-left: 10px;
		}
	}

	@media (max-width: 1120px) {
		.content_bg {
			width: calc(1120px * 0.8);
		}

		.enterpriseDynamicsList .newArea,
		.enterpriseDynamicsList .newsImg,
		.news-list .newcontent,
		.news-list .newcontent .newcontentcontainer,
		.enterpriseDynamicsList .news-list .news-item {
			height: calc(1px * ((1120 * 0.8 - 140) * 4 / 24* 520 / 720)) !important;
		}

		.enterpriseDynamicsList .news-list .news-item .newsImg img {
			width: calc(1px * ((1120 * 0.8 - 140) * 4 / 24));
			height: calc(1px * ((1120 * 0.8 - 140) * 4 / 24 * 520 / 720)) !important;
		}

		.news-list .newcontent .newcontentcontainer {
			height: calc(1px * ((1120 * 0.8 - 140) * 4 / 24 * 520 / 720)) !important;
		}

		.enterpriseDynamicsList .news-list .news-item .title {
			height: 26px;
			line-height: 26px;
			font-size: 14px;
		}

		.enterpriseDynamicsList .news-list .newcontent .description {
			font-size: 12px;
			height: 36px;
			line-height: 18px;
		}

		.enterpriseDynamicsList .newArea {
			margin-bottom: 20px;
		}

		.enterpriseDynamicsList .news-list .news-item {
			margin-bottom: 20px !important;
		}

		.enterpriseDynamicsList .moreInfoBtn {
			width: 75px;
			height: 24px;
			line-height: 24px;
			margin-top: 0px !important;
			margin-left: 10px;
			font-size: 12px;
		}

	}

	@media (max-width: 1024px) {
		.content_bg {
			width: calc(1024px * 0.8);
		}

		.enterpriseDynamics .content_bg {
			width: calc(1024px * 0.8);
		}

		.enterpriseDynamicsList .newArea,
		.enterpriseDynamicsList .newsImg,
		.news-list .newcontent,
		.news-list .newcontent .newcontentcontainer,
		.enterpriseDynamicsList .news-list .news-item {
			height: calc(1px * ((1024 * 0.8 - 100) * 4 / 24* 520 / 720)) !important;
		}

		.enterpriseDynamicsList .news-list .news-item .newsImg img {
			width: calc(1px * ((1024 * 0.8 - 100) * 4 / 24));
			height: calc(1px * ((1024 * 0.8 - 100) * 4 / 24 * 520 / 720)) !important;
		}

		.news-list .newcontent .newcontentcontainer {
			height: calc(1px * ((1024 * 0.8 - 100) * 4 / 24 * 520 / 720)) !important;
		}

		.enterpriseDynamicsList .news-list .news-item .title {
			height: 24px;
			line-height: 24px;
			font-size: 12px;
			font-weight: 530px;
		}

		.enterpriseDynamicsList .news-list .newcontent .description {
			font-size: 12px;
			height: 36px;
			line-height: 18px;
		}

		.enterpriseDynamicsList .newArea {
			margin-bottom: 20px;
		}

		.enterpriseDynamicsList .news-list .news-item {
			margin-bottom: 20px !important;
		}

		.enterpriseDynamicsList .moreInfoBtn {
			width: 60px;
			height: 20px;
			line-height: 20px;
			margin-top: 0px;
			margin-left: 10px;
			font-size: 11px;
		}
	}

	@media (max-width: 768px) {
		.content_bg {
			width: 100%;
		}

		.enterpriseDynamicsList .news-list .news-item .title {
			height: 24px;
			line-height: 24px;
			font-size: 12px;
			font-weight: 530px;
		}

		.enterpriseDynamicsList .news-list .newcontent .description {
			font-size: 12px;
			height: 40px;
			line-height: 22px;
		}
	}
</style>
